﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using Volo.Abp.Domain.Entities;

namespace CommonManagement
{
    /// <summary>
    /// 天气类
    /// </summary>
    public class Weather : BasicAggregateRoot<int>
    {
        private readonly static DateTime today = new DateTime(2022, 4, 21);

        /// <summary>日期</summary>
        public DateTime Date { get; protected set; }

        /// <summary>更新时间</summary>
        public string UpdateTime { get; protected set; }

        /// <summary>温湿度信息</summary>
        public TempInfo TempInfo { get; protected set; }

        /// <summary>风力信息</summary>
        public Wind Wind { get; protected set; }

        /// <summary>舒适度</summary>
        public ComfortLevel ComfortLevel { get; protected set; }

        /// <summary>空气质量</summary>
        public AirQuantity AirQuantity { get; protected set; }

        /// <summary>分时集合</summary>
        public IList<Division> Divisions { get; protected set; }

        private Weather() { }

        /// <summary>标签</summary>
        [NotMapped]
        public string Label
        {
            get
            {
                var diff = (Date - today).Days;
                switch (diff)
                {
                    case -1:
                        return "昨天";
                    case 0:
                        return "今天";
                    case 1:
                        return "明天";
                    default:
                        return WeekName(Date.DayOfWeek);
                }
            }
        }

        /// <summary>日期</summary>
        [NotMapped]
        public string Day
        {
            get
            {
                return Date.ToString("MM月dd日");
            }
        }

        /// <summary>
        /// 周名称
        /// </summary>
        /// <param name="week"></param>
        private string WeekName(DayOfWeek week)
        {
            switch (week)
            {
                case DayOfWeek.Sunday:
                    return "星期日";
                case DayOfWeek.Monday:
                    return "星期一";
                case DayOfWeek.Tuesday:
                    return "星期二";
                case DayOfWeek.Wednesday:
                    return "星期三";
                case DayOfWeek.Thursday:
                    return "星期四";
                case DayOfWeek.Friday:
                    return "星期五";
                case DayOfWeek.Saturday:
                    return "星期六";
                default:
                    return "未知";
            }
        }
    }
}